//
//  expertsLibraryTVCell.m
//  zhuanJia
//
//  Created by 吕超 on 16/12/2.
//  Copyright © 2016年 lc. All rights reserved.
//





#import "expertsLibraryTVCell.h"
#import "Masonry.h"
// 设置颜色
#define UIColorRGB(x,y,z) [UIColor colorWithRed:x/255.0 green:y/255.0 blue:z/255.0 alpha:1.0]
// 屏幕宽
#define selfWidth [UIScreen mainScreen].bounds.size.width
// 屏幕高
#define selfHeigh   [UIScreen mainScreen].bounds.size.height
@implementation expertsLibraryTVCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self){
     
        [self createSubView];
    }
    return self;
}

// 创建子视图
- (void)createSubView{
    
    // 防止循环引用
      __weak typeof(self) WeakSelf = self;
    //多余 空白处 颜色
    self.backgroundColor = UIColorRGB(243, 243, 243);
    
    // cell 选中 无颜色改变
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    
    
    
#pragma mark ====  头像
    _headView = [[UIImageView alloc]initWithFrame:CGRectMake(5, 5, 45, 45)];
    
    //圆角效果  动画效果没有切角失效
    
    _headView.layer.masksToBounds = YES;
    //高的一半切成圆
    _headView.layer.cornerRadius = _headView.frame.size.height/2;
    
    //设置边界外内容不显示
    _headView.clipsToBounds = YES;
    

    _headView.image = [UIImage imageNamed:@"img_default"];
    
#pragma mark  ====  白背景
    _backView = [[UIImageView alloc]init];
    
    self.backView.image = [UIImage imageNamed:@"expertsbackView"];
    
    [self addSubview:self.backView];
    
    [self addSubview:self.headView];
    
#pragma mark  ====   专家 名
  
    self.NameLabel = [[UILabel alloc]init];
 
    [self addSubview:self.NameLabel];
    self.NameLabel.font = [UIFont boldSystemFontOfSize:14];
    [self.NameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        // 底部  与  头像  对齐
        make.bottom.mas_equalTo(WeakSelf.headView);
        //  顶部距离白色背景5
        make.top.mas_equalTo(35);
        
        make.left.mas_equalTo(65);
        
        make.right.mas_equalTo(-10);
    }];



    
    //内容label
    self.contentLabel = [[UILabel alloc]init];
    
    _contentLabel.numberOfLines = 2;
    
    _contentLabel.font = [UIFont systemFontOfSize:12];

    _contentLabel.textColor = UIColorRGB(153, 153, 153);
    
    [self addSubview:self.contentLabel];
    
     _contentLabel.frame = CGRectMake(65, CGRectGetMaxY(self.firstBtn.frame) + 7,selfWidth - 80, 35);
    
    [_backView mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_equalTo(27);
        make.left.mas_equalTo(5);
        make.right.mas_equalTo(-5);
        make.bottom.mas_equalTo(_contentLabel).offset(7);
    }];

}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
